package com.danger.util;

import android.util.Log;
import android.view.animation.Animation;

import com.danger.widget.MyCircleImageView;

/**
 * Created by 俊 on 2016/8/17.
 */
public class AnimationUtil {

    private MyCircleImageView imageView;
    private Animation animation;
    private long position;

    public AnimationUtil(MyCircleImageView imageView, Animation animation) {
        this.imageView = imageView;
        this.animation = animation;
    }

    public void startAnimation() {
        imageView.startAnimation(animation);
    }

    public void pauseAnimation() {
        this.position = animation.getStartTime() % 1000000;
        Log.i("position", position + "");
        imageView.clearAnimation();
        float degree = ((float) position) / 1000000 * 360;
        Log.i("position", "degree : " + degree);
        imageView.setRotation(degree);
    }

    public void continueAnimation() {
        animation.setStartTime(position);
        imageView.startAnimation(animation);
    }

}